$(function () {
    function f(a) {
        for (var c = a.find("ul"), b = c.children().length, d = 1; d < b; d++)c.find("li:eq(" + (b - 1 - d) + ")").appendTo(c);
        for (b = 0; 5 > b; b++)c.find("li:last").prependTo(c);
        a.feedSlider({direction:"right"})
    }

    function g(a, c) {
        var b = c.width() * a.height() / c.height();
        b > a.width() && (b = (b - a.width()) / 2, c.css("marginLeft", -b))
    }

    GUANGER.userId.length ? ($("#J_legend").hide(), $("#J_welcome").html('<div class="welcome"><a class="xihuan" href="http://guang.com/xihuan" title="\u53d1\u73b0.\u559c\u6b22"></a><a class="zhuti" href="http://guang.com/jie" title="\u901b\u4e3b\u9898"></a><a class="pingpai" href="http://guang.com/pinpai" title="\u8bfb\u54c1\u724c"></a><a class="fenxiang" href="http://guang.com/square" title="\u5206\u4eab,\u6536\u83b7"></a><a class="home" href="http://guang.com/u/' +
        GUANGER.userId + '" title="\u6211\u7684\u5c0f\u7a9d~"></a></div>')) : $(".thirdLogin a").click(function () {
        var a = $(this).attr("href");
        jQuery.guang.util.openWin(a);
        return!1
    });
    f($("#J_DarenRecomm"));
    f($("#J_LatestLike"));
    $("#J_login").click(function (a) {
        a.preventDefault();
        jQuery.guang.dialog.isLogin()
    });
    $("body").css("height", "auto");
    $(".startbtn").click(function () {
        $(".startbg").animate({marginTop:-1 * $("body").height()}, 500, function () {
            $(".startbg").hide();
            $(".thepage").fadeIn();
            $("body").css("height", "auto")
        })
    });
    $(".startpage .guys li").hover(function () {
        $(this).find(".name").animate({bottom:0}, 200)
    }, function () {
        $(this).find(".name").animate({bottom:-18}, 200)
    });
    $(".guys").data("loaded", !1);
    $(".g-logo .goup").click(function (a) {
        a.preventDefault();
        $(".startbg").show();
        $(".thepage").hide();
        $("html").css("height", "100%");
        $("body").css("height", "100%");
        $(".startbg").css("marginTop", -1 * $("body").height() + "px");
        $(".guys").hide();
        $(".startbg").animate({marginTop:0}, 500, function () {
            if (!$(".guys").data("loaded")) {
                for (var a =
                    $(".guys li").not(".guys-joinus"), b = 0; b < 29; b++) {
                    var d;
                    d = Math.floor(a.length * Math.random());
                    d = a.slice(d, d + 1);
                    var a = a.not(d[0]), e = d.find("img").data("origin");
                    d.find("img").attr("src", e)
                }
                a.remove();
                $(".guys").data("loaded", true)
            }
            $(".guys").fadeIn()
        })
    });
    $(".scrollable").scrollImg({timer:1E4, startHandle:function (a) {
        a && setTimeout(function () {
            a.playlol(0);
            a.changeClass(0);
            a.autoPlay()
        }, 1E4);
        var c = null;
        $(".navi li").each(function (b) {
            $(this).unbind();
            $(this).hover(function () {
                c != null && clearTimeout(c);
                c = setTimeout(function () {
                    a.changeClass(b);
                    a.stopAuto();
                    a.playlol(b)
                }, 200)
            }, function () {
                c != null && clearTimeout(c);
                a.autoPlay()
            })
        })
    }});
    $(".category img, .brands img").lazyload({effect:"fadeIn", threshold:200});
    var e = $("#J_TabNav"), h = $("#J_MoreTabNav");
    e.tabs("#J_TabPanels .bd", {event:"click", tabs:"a", current:"on"});
    e.data("tabs").onClick(function (a) {
        a = a || window.event;
        a = a.srcElement || a.target;
        h.find("a").removeClass("on");
        h.find("a[data-tab=" + $(a).data("tab") + "]").addClass("on")
    });
    $(".startpage .guys li").hover(function () {
        $(this).find(".name").animate({bottom:0},
            200)
    }, function () {
        $(this).find(".name").animate({bottom:-18}, 200)
    });
    e = $("#J_GalleryPop");
    window.location.hash && "#fashion" == window.location.hash && e.css("display", "block");
    e.find(".big, .mid").each(function () {
        g($(this), $(this).find("img:first"))
    });
    e.find(".small").live("mouseover", function () {
        var a = $(this), c = $.browser.msie ? 80 : 200, b = a.closest(".item").find(".mid");
        b.animate({height:22}, c);
        b.attr("class", "small");
        a.animate({height:90}, c);
        a.attr("class", "mid");
        a = a.find("img:first");
        a.attr("src", a.data("src"));
        g(a.parent(), a)
    })
});
